package com.yilong.wei.app.commons;

import com.yilong.wei.app.config.UploadFileConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class WebConfigurer implements WebMvcConfigurer {

    @Autowired
    private UploadFileConfig uploadFileConfig;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(uploadFileConfig.getBasePath()+"**").addResourceLocations("file:"+uploadFileConfig.getUploadPath());
    }

}
